﻿using System;

namespace XTengine.ComponentModel
{
    public class StringConverter : TypeConverter<String>
    {
        public override String ConvertFrom(string value)
        {
            string[] words = value.Split(new[] { "%20" }, StringSplitOptions.None);

            string result = string.Empty;

            foreach (string word in words)
                result += word + " ";

            result.Trim();

            return result;
        }

        public override string ConvertTo(string value)
        {
            string[] words = value.Split(' ');

            string result = string.Empty;
            foreach (string word in words)
	        {
		        result += word;
                result += "%20";
	        }

            result.Trim();

            return result;
        }
    }
}